build,win: enable PGO and LTO for Windows builds#62761
build,win: enable PGO and LTO for Windows builds#62761nodejs-github-bot merged 4 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
|
Since there are 3 approvals and the CI has passed, I'll add the |
Commit Queue failed- Loading data for nodejs/node/pull/62761 ✔ Done loading data for nodejs/node/pull/62761 ----------------------------------- PR info ------------------------------------ Title build,win: enable PGO and LTO for Windows builds (#62761) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch StefanStojanovic:mefi-win-pgo -> nodejs:main Labels windows, build, v8 engine, openssl, tools, i18n-api, needs-ci, dependencies, icu Commits 4 - build,win: enable x64 PGO - build,win: change LTCG to thin LTO - build,win: enable full LTO - build,win: enable ARM64 PGO Committers 1 - StefanStojanovic <stefan.stojanovic@janeasystems.com> PR-URL: https://github.com/nodejs/node/pull/62761 Refs: https://github.com/nodejs/node/issues/61964 Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/62761 Refs: https://github.com/nodejs/node/issues/61964 Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> -------------------------------------------------------------------------------- ℹ This PR was created on Wed, 15 Apr 2026 17:55:08 GMT ✔ Approvals: 3 ✔ - Xuguang Mei (@meixg): https://github.com/nodejs/node/pull/62761#pullrequestreview-4120394786 ✔ - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/62761#pullrequestreview-4131453924 ✔ - Tobias Nießen (@tniessen) (TSC): https://github.com/nodejs/node/pull/62761#pullrequestreview-4135179752 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2026-04-17T08:01:16Z: https://ci.nodejs.org/job/node-test-pull-request/72734/ - Querying data for job/node-test-pull-request/72734/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 62761 From https://github.com/nodejs/node * branch refs/pull/62761/merge -> FETCH_HEAD ✔ Fetched commits as d44a71a25111..c58fb1f05b3e -------------------------------------------------------------------------------- Auto-merging common.gypi Auto-merging configure.py Auto-merging node.gyp Auto-merging vcbuild.bat [main a8fd13f7e7] build,win: enable x64 PGO Author: StefanStojanovic <stefan.stojanovic@janeasystems.com> Date: Fri Feb 27 14:18:04 2026 +0100 4 files changed, 77 insertions(+), 22 deletions(-) Auto-merging configure.py Auto-merging node.gyp [main 225ed5cbe7] build,win: change LTCG to thin LTO Author: StefanStojanovic <stefan.stojanovic@janeasystems.com> Date: Fri Feb 27 16:13:38 2026 +0100 2 files changed, 27 insertions(+), 32 deletions(-) Auto-merging common.gypi Auto-merging configure.py Auto-merging node.gyp Auto-merging vcbuild.bat [main d21c15f2fa] build,win: enable full LTO Author: StefanStojanovic <stefan.stojanovic@janeasystems.com> Date: Thu Mar 19 09:07:54 2026 +0100 9 files changed, 255 insertions(+), 6 deletions(-) Auto-merging common.gypi Auto-merging configure.py [main 182e805eca] build,win: enable ARM64 PGO Author: StefanStojanovic <stefan.stojanovic@janeasystems.com> Date: Thu Mar 26 11:41:44 2026 +0100 2 files changed, 47 insertions(+), 19 deletions(-) ✔ Patches applied There are 4 commits in the PR. Attempting autorebase. (node:347) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated. (Use `node --trace-deprecation ...` to show where the warning was created) Rebasing (2/8) Executing: git node land --amend --yes --------------------------------- New Message ---------------------------------- build,win: enable x64 PGOhttps://github.com/nodejs/node/actions/runs/24834484916 |
Description
This PR enables Profile-Guided Optimization (PGO) and Link-Time Optimization (LTO) for Windows builds (x64 and ARM64). The changes used the Linux implementation of these optimizations as guidelines. They can be used separately, but can also be used alongside each other for the best results.
PGO
PGO adds 2 new, mutually exclusive, vcbuild options:
pgo-generate- for building an instrumented binary for generating profile datapgo-use- for building an optimized binary using the generated profile dataPGO is planned to be used like this:
vcbuild.bat pgo-generate- builds instrumented binaryvcbuild.bat pgo-use- builds optimized binaryLTO
On Windows, LTCG was used for a long time. Since moving to ClangCL, LTO is an option, and this PR adds support for it. Together with adapting the legacy LTCG option (which is still available and used for release builds), there are 2 new LTO options in vcbuild. All 3 are mutually exclusive:
ltcg- since LTCG is an MSVC-specific optimization, it is now changed to apply thin LTO, but only to the Node.js executable. This is how LTCG was applied previously.thin-lto- applies thin LTO to all projects (except build-time tools)lto- applies full LTO to all projects (except build-time tools)Next steps
This PR simply enables using PGO and/or LTO in Windows builds, and as such, is a good starting point, but in order to capitalize on it, more work is needed in the future. Because of this, I believe these changes are safe to land, as they just enable optimizations, without forcing them anywhere. Here is a rough set of a few future steps we could take if we wanted to leverage this:
ltcgoption, and start usingthin-ltofor Windows builds. This is a simple change to make, but we need to investigate how it will affect build time and performance, as we do not want to make the Windows compilation job a bottleneckRefs: #61964